import { init } from 'echarts';
import React, { createRef } from 'react';

export default class extends React.Component {

  chartRef = createRef(null);

  instance = null;

  componentDidMount () {
    this.instance = init(this.chartRef.current);
    this.instance.setOption(this.props.option);
  }

  componentDidUpdate () {
    this.instance.setOption(this.props.option);
  }

  render () {
    return <div ref={ this.chartRef } className="chart" />;
  }

}
